package com.weeho.dongyong.beanPackage;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * spring线程池配置
 * Created by xiejh on 2016/10/31.
 */
@Configuration
@EnableCaching
@EnableAsync
public class ThreadPoolTaskExecutorBean  extends AsyncConfigurerSupport{

    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(50);
        executor.setQueueCapacity(2000);
        executor.initialize();
        return executor;
    }


}
